﻿using System;
using System.Collections;

namespace YArchitech.HCLoad.XmlData
{
	public class OrientationFixs : Hashtable
	{
		public OrientationFixs(Building building)
		{
			this.parent = building;
			this.LoadOrientationFixs();
		}

		public Building Parent
		{
			get
			{
				return this.parent;
			}
			set
			{
				this.parent = value;
			}
		}

		public void AddOrientationFix(OrientationFix orientationFix)
		{
			try
			{
				orientationFix.Parent = this;
				this.Add(orientationFix.Direction, orientationFix);
			}
			catch (Exception ex)
			{
				throw new Exception(ex.ToString());
			}
		}

		public void RemoveOrientationFix(string Direction)
		{
			try
			{
				this.Remove(Direction);
			}
			catch (Exception ex)
			{
				throw new Exception(ex.ToString());
			}
		}

		public OrientationFix GetOrientationFix(string Direction)
		{
			OrientationFix result;
			try
			{
				result = (OrientationFix)this[Direction];
			}
			catch (Exception ex)
			{
				throw new Exception(ex.ToString());
			}
			return result;
		}

		private void LoadOrientationFixs()
		{
			try
			{
				OrientationFix orientationFix = new OrientationFix(this);
				orientationFix.Direction = "北";
				orientationFix.FwjXz = 0.1;
				this.Add(orientationFix.Direction, orientationFix);
				orientationFix = new OrientationFix(this);
				orientationFix.Direction = "东北";
				orientationFix.FwjXz = 0.1;
				this.Add(orientationFix.Direction, orientationFix);
				orientationFix = new OrientationFix(this);
				orientationFix.Direction = "东";
				orientationFix.FwjXz = -0.05;
				this.Add(orientationFix.Direction, orientationFix);
				orientationFix = new OrientationFix(this);
				orientationFix.Direction = "东南";
				orientationFix.FwjXz = -0.1;
				this.Add(orientationFix.Direction, orientationFix);
				orientationFix = new OrientationFix(this);
				orientationFix.Direction = "南";
				orientationFix.FwjXz = -0.25;
				this.Add(orientationFix.Direction, orientationFix);
				orientationFix = new OrientationFix(this);
				orientationFix.Direction = "西南";
				orientationFix.FwjXz = -0.1;
				this.Add(orientationFix.Direction, orientationFix);
				orientationFix = new OrientationFix(this);
				orientationFix.Direction = "西";
				orientationFix.FwjXz = -0.05;
				this.Add(orientationFix.Direction, orientationFix);
				orientationFix = new OrientationFix(this);
				orientationFix.Direction = "西北";
				orientationFix.FwjXz = 0.1;
				this.Add(orientationFix.Direction, orientationFix);
			}
			catch (Exception ex)
			{
				throw new Exception(ex.ToString());
			}
		}

		private Building parent;
	}
}
